1. Field of the Invention
This invention relates to a pattern matching method used to read printed material on a food package and to a pattern matching apparatus.
2. Description of the Related Art
In general, on a food package, in addition to the print on the package itself, the freshness date, etc., is printed after the contents are enclosed in the package. To print such a date, various print methods such as marking, branding, etc., are used.
In the food industry, so-called stamp marking using ink rather than punching is often used and is applied to various materials particularly if the surfaces are flat. The brand is applied to packages made of paper, etc., and is a very handy method often used for milk cartons, etc.
Image processing is performed to check if the dates printed on the packages using the print methods are the correct dates at the final stage of manufacturing. Specifically, the printed date is imaged by an image reading device, the date portion is obtained from the imaging result and is binarized, the binarized date portion is matched with previously stored dictionary data as a pattern image. If the matching result matches the date on a timer installed into the matching device, a determination of quality is made.
There is a problem, however, that the line width of the date printed by marking becomes gradually narrow as the amount of ink in the printer decreases or the print pressure lowers, and so-called xe2x80x9cthin spotsxe2x80x9d easily occur, causing an erroneous determination to be made. In contrast, if the ink amount is large or the print pressure is high, so-called xe2x80x9cbleedingxe2x80x9d easily occurs in the edges of the printed date, also causing an erroneous determination. The line width is also made narrow as a result of the lighting.
A date printed by branding has an uneven print density at the edges and an inner portion and in addition, it is easily affected by lighting because the print density is comparatively low. Therefore, it is hard to obtain the date portion based on brightness distribution, and it is possible that the inner portion rather than the edges of the binarized date portion may be recognized as the background portion, resulting in error.
However, in the print application of the freshness date, etc., as described above, the object is to determine whether the date is correct, and the print quality of the date is not a question. That is, the manufacturer expects that a quality determination may be made if a thin spot, bleeding, print unevenness, thinning, etc., is to such an extent that the consumer can identify the correct date.
In view of the above problems, it is an object of the invention to provide a pattern matching method unlikely to be affected by thin spots, bleeding, print unevenness, thinning, etc., and to provide a pattern matching apparatus used to execute the method.
According to a first aspect of the invention, a pattern matching method comprises the steps of: performing expansion processing for a preset pattern image used as a matching candidate, thereby preparing a first pattern image; at least one of (a) performing contraction processing for the preset pattern image, thereby preparing a second pattern image, and (b) using the preset pattern image as the second pattern image; finding a differential image between the first and second pattern images; preparing a mask image based on the differential image; and performing matching processing of an image containing a character to be recognized with the pattern image with respect to pixels in an area other than the prepared mask image.
According to a second aspect of the invention, a pattern matching apparatus comprises: first pattern image preparation means for performing expansion processing for a preset pattern image used as a matching candidate, thereby preparing a first pattern image; second pattern image preparation means for at least one of (a) performing contraction processing for the preset pattern image, thereby preparing a second pattern image, and (b) using the preset pattern image as the second pattern image; differential image preparation means for preparing a differential image between the first and second pattern images; mask image preparation means for preparing a mask image based on the differential image prepared by said differential image preparation means; and matching processing means for performing matching processing of an image containing a character to be recognized with the pattern image with respect to pixels in an area other than the mask image prepared by the mask image preparation means.